package com.dragon.app.commons.dto;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

import com.alibaba.fastjson.JSON;
import com.dragon.loan.entity.AcLoanApplyInfo;
import com.fintech.common.enums.DateFormatEnum;
import com.fintech.user.entity.RealNameAuthentication;
import com.marvels.common.utils.MarvelsLogUtil;

public class ProductApplyDTO  implements Serializable{
	private static final long serialVersionUID = 1L;

	private String loanId;
	private Long productId;
	private String productName;
	private Integer applyTerms;
	private BigDecimal applyMoney;
	private String custTypeId;
	private String custTypeName;
	private String usedTypeId;
	private String usedTypeName;
	private String usedCharacter;
	private String usedOther;
	private String referrerMobileNum;
	private String deviceId;
	private Double lat;
	private Double lon;
	private String wifiaddress;
	private String insurantType;//车险分期特有
	private String province;
	private String city;
	private String source;
	/**
	 * 复贷标识（0：否 1：是）
	 */
	private String reloanFlag;

	/**
	 * 复贷贷款编号
	 */
	private String reloanId;

	public static AcLoanApplyInfo getAcLoanApplyInfo(ProductApplyDTO productApplyDTO,
			RealNameAuthentication realNameAuthentication) {
		AcLoanApplyInfo acLoanApplyInfo = new AcLoanApplyInfo();
		acLoanApplyInfo.setProductTypeName(productApplyDTO.getProductName());
		acLoanApplyInfo.setProductName(productApplyDTO.getProductName());
		acLoanApplyInfo.setApplyTerms(productApplyDTO.getApplyTerms());
		acLoanApplyInfo.setApplyMoney(productApplyDTO.getApplyMoney());
		acLoanApplyInfo.setReferrerMobileNum(productApplyDTO.getReferrerMobileNum());
		acLoanApplyInfo.setUsedId(productApplyDTO.getUsedTypeId());
		acLoanApplyInfo.setUsedName(productApplyDTO.getUsedTypeName());
		acLoanApplyInfo.setUsedCharacter(productApplyDTO.getUsedCharacter());
		acLoanApplyInfo.setUsedOther(productApplyDTO.getUsedOther());

		// 填充实名验证的数据
		acLoanApplyInfo.setUserId(realNameAuthentication.getUserId() + "");
		acLoanApplyInfo.setCustIdCard(realNameAuthentication.getIdentityCardNo());
		acLoanApplyInfo.setCustName(realNameAuthentication.getRealName());
		acLoanApplyInfo.setIdCardAddress(realNameAuthentication.getAddress());
		acLoanApplyInfo.setNationality(realNameAuthentication.getNation());
		acLoanApplyInfo.setIdCardValidDate(realNameAuthentication.getValidityfrom());
		acLoanApplyInfo.setIdCardValidEndDate(realNameAuthentication.getValidityto());
		acLoanApplyInfo.setCertificateAuthority(realNameAuthentication.getAuthority());
		Integer sex = realNameAuthentication.getSex();
		String identityCardNo = realNameAuthentication.getIdentityCardNo();
		acLoanApplyInfo.setSex(sex == null ? "" : sex + "");
		Date birthDate = com.fintech.common.util.DateTimeUtil.formatStrDate(DateFormatEnum.yyyyMMdd, identityCardNo.substring(6, 14));
		acLoanApplyInfo.setBirthDate(birthDate);
		try {
			acLoanApplyInfo.setAge(com.fintech.common.util.DateTimeUtil.getAge(birthDate));
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error("===========setAge=================", e);
		}
		return acLoanApplyInfo;
	}

	public static AcLoanApplyInfo getAcLoanApplyInfo(ProductApplyDTO productApplyDTO) {
		AcLoanApplyInfo acLoanApplyInfo = new AcLoanApplyInfo();
		acLoanApplyInfo.setLoanId(productApplyDTO.getLoanId());
		acLoanApplyInfo.setProductTypeName(productApplyDTO.getProductName());
		acLoanApplyInfo.setProductName(productApplyDTO.getProductName());
		acLoanApplyInfo.setApplyTerms(productApplyDTO.getApplyTerms());
		acLoanApplyInfo.setApplyMoney(productApplyDTO.getApplyMoney());
		acLoanApplyInfo.setWorkType(productApplyDTO.getCustTypeId());
		acLoanApplyInfo.setWorkTypeId(productApplyDTO.getCustTypeId());
		acLoanApplyInfo.setUsedId(productApplyDTO.getUsedTypeId());
		acLoanApplyInfo.setUsedName(productApplyDTO.getUsedTypeName());
		acLoanApplyInfo.setUsedCharacter(productApplyDTO.getUsedCharacter());
		acLoanApplyInfo.setUsedOther(productApplyDTO.getUsedOther());
		acLoanApplyInfo.setReferrerMobileNum(productApplyDTO.getReferrerMobileNum());
		return acLoanApplyInfo;
	}

	public String getUsedCharacter() {
		return usedCharacter;
	}

	public void setUsedCharacter(String usedCharacter) {
		this.usedCharacter = usedCharacter;
	}

	public String getUsedOther() {
		return usedOther;
	}

	public void setUsedOther(String usedOther) {
		this.usedOther = usedOther;
	}

	public String getDeviceId() {
		return deviceId;
	}

	public void setDeviceId(String deviceId) {
		this.deviceId = deviceId;
	}

	public Double getLat() {
		return lat;
	}

	public String getSource() {
		return source;
	}

	public void setSource(String source) {
		this.source = source;
	}

	public String getInsurantType() {
		return insurantType;
	}

	public void setInsurantType(String insurantType) {
		this.insurantType = insurantType;
	}

	public void setLat(Double lat) {
		this.lat = lat;
	}

	public Double getLon() {
		return lon;
	}

	public void setLon(Double lon) {
		this.lon = lon;
	}

	public String getWifiaddress() {
		return wifiaddress;
	}

	public void setWifiaddress(String wifiaddress) {
		this.wifiaddress = wifiaddress;
	}

	public String getReferrerMobileNum() {
		return referrerMobileNum;
	}

	public void setReferrerMobileNum(String referrerMobileNum) {
		this.referrerMobileNum = referrerMobileNum;
	}

	public String getUsedTypeId() {
		return usedTypeId;
	}

	public void setUsedTypeId(String usedTypeId) {
		this.usedTypeId = usedTypeId;
	}

	public String getUsedTypeName() {
		return usedTypeName;
	}

	public void setUsedTypeName(String usedTypeName) {
		this.usedTypeName = usedTypeName;
	}

	public String getLoanId() {
		return loanId;
	}

	public void setLoanId(String loanId) {
		this.loanId = loanId;
	}

	public Long getProductId() {
		return productId;
	}

	public void setProductId(Long productId) {
		this.productId = productId;
	}

	public String getProductName() {
		return productName;
	}

	public void setProductName(String productName) {
		this.productName = productName;
	}

	public Integer getApplyTerms() {
		return applyTerms;
	}

	public void setApplyTerms(Integer applyTerms) {
		this.applyTerms = applyTerms;
	}

	public BigDecimal getApplyMoney() {
		return applyMoney;
	}

	public void setApplyMoney(BigDecimal applyMoney) {
		this.applyMoney = applyMoney;
	}

	public String getCustTypeId() {
		return custTypeId;
	}

	public void setCustTypeId(String custTypeId) {
		this.custTypeId = custTypeId;
	}

	public String getCustTypeName() {
		return custTypeName;
	}

	public void setCustTypeName(String custTypeName) {
		this.custTypeName = custTypeName;
	}

	public String getProvince() {
		return province;
	}

	public void setProvince(String province) {
		this.province = province;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}



	@Override
	public String toString() {
		return JSON.toJSONString(this);
	}

	public static void main(String[] args) {
		Date formatStrDate = com.fintech.common.util.DateTimeUtil.formatStrDate(DateFormatEnum.yyyy0MM0dd, "19951204");
		System.out.println(formatStrDate);
	}

	public String getReloanFlag() {
		return reloanFlag;
	}

	public void setReloanFlag(String reloanFlag) {
		this.reloanFlag = reloanFlag;
	}

	public String getReloanId() {
		return reloanId;
	}

	public void setReloanId(String reloanId) {
		this.reloanId = reloanId;
	}

}
